package com.letoken.platform.repo.admin.manager;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.letoken.platform.repo.app.dao.AppUserIssueRecordMapper;
import com.letoken.platform.repo.app.po.AppUserIssueRecord;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * @author wyl
 * @date 2023/1/5 19:23
 * @Version 1.0
 */
@Log4j2
@Repository
public class AppUserIssueRecordManager {
    @Autowired
    private AppUserIssueRecordMapper issueRecordMapper;

    /**
     * 根据用户id查询正在流通的流通订单 根据时间正序排序
     * @param userId
     * @return
     */
    public List<AppUserIssueRecord> queryIssueRecordListByUserId(Integer userId){
        LambdaQueryWrapper<AppUserIssueRecord> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(AppUserIssueRecord::getUserId,userId)
                .eq(AppUserIssueRecord::getStatus,0)
                .gt(AppUserIssueRecord::getWaitCirculation,0)
                .orderByDesc(AppUserIssueRecord::getCreateTime);
        List<AppUserIssueRecord> issueRecordsList = issueRecordMapper.selectList(queryWrapper);
        return issueRecordsList;
    }

}
